package com.starchen.optimalselection.web.controller;

import com.starchen.optimalselection.common.utils.Result;
import com.starchen.optimalselection.common.model.Advertise;
import com.starchen.optimalselection.common.model.SkuInfo;
import com.starchen.optimalselection.web.service.HomeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 首页轮播广告管理Controller
 * Created by daxilong on 2022/11/7.
 */
@RestController
@Api(tags = "首页轮播广告管理")
@RequestMapping("/api/home")
public class HomeController {

    @Autowired
    private HomeService homeService;

    @ApiOperation(value = "查询所有上架的广告")
    @GetMapping(value = "/banner")
    public Result list() {
        List<Advertise> list = homeService.getBannerList();
        return Result.success(list);
    }

    @ApiOperation("分页获取人气推荐商品")
    @GetMapping(value = "/recommend")
    public Result hotProductList() {
        List<SkuInfo> productList = homeService.getRecommendList();
        return Result.success(productList);
    }

    @ApiOperation("分页获取新品推荐商品")
    @GetMapping(value = "/new")
    public Result newProductList() {
        List<SkuInfo> productList = homeService.getNewList();
        return Result.success(productList);
    }

}
